<%--
  Created by IntelliJ IDEA.
  User: fyf
  Date: 2018/11/8
  Time: 17:04
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@ include file="/common/taglib.jsp" %>
<%
  session.getAttribute("branchid");
%>
<html>
<head>
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
  <meta charset="utf-8"/>
  <title>分公司账户管理</title>
  <meta name="description" content="overview &amp; stats"/>
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"/>
  <jsp:include page="/common/basecss.jsp" flush="true"/>
  <script src="${pageContext.request.contextPath}/js/jquery-2.1.0.js"></script>
  <script src="${pageContext.request.contextPath}/assets/js/layer-v3.1.0/layer/layer.js"></script>
  <link href="https://cdn.bootcss.com/twitter-bootstrap/3.0.1/css/bootstrap-theme.css" rel="stylesheet">
</head>
<body>
<div class="container">
  <div class="row clearfix">
    <div class="col-md-12 column">
      <form role="form" method="post" action="">
        <div class="form-group">
          <label for="username">用户名</label>
          <input type="text" class="form-control" id="username"
                 name="username" required="required" value="${user.username}"/>
        </div>
        <div class="form-group">
          <label for="password">密码</label>
          <input type="password" class="form-control" id="password"
                 name="password" required="required" value="${user.password}"/>
        </div>
        <div class="form-group">
          <label for="comment">分公司名称</label>
          <input type="text" class="form-control" id="comment"
                 name="comment" required="required" value="${user.comment}"/>
        </div>
        <div>
          <label for="issuper">是否为管理员用户</label>
          <select name="issuper" id="issuper">
            <option value="0">否</option>
            <option value="1">是</option>
          </select>
        </div><input name="id" value="${user.id}" hidden="hidden">
        <input name="branchid" value="${user.branchid}" hidden="hidden">
        <div class="checkbox">
        </div>

      </form>
     <button class="btn btn-default" id="submitButton">提交</button>
    </div>
  </div>
</div>



<script>
    $(function () {
        /*ajax提交，成功之后父级页面刷新*/
        /*$("#submitButton").click(function () {
            $("#classForm").submit();
            layer.load(1,{shade: false});
            setTimeout(function () {
                parent.location.reload();
            }, 2000);

        });*/
        $("#submitButton").click(function () {



            var $params = "username="+$('#username').val()+"&password="+$('#password').val()+"&comment="
                +$('#comment').val() + "&issuper="+$('#issuper').val()

            $.ajax({
                type:'post',
                url:'addUser.go',
                data:$params,
                dataType:'json',
                success:function (resData) {


                    if (resData.status == 200 ){
                        layer.msg(resData.message+'成功',{icon: 1});
                        setTimeout(function () {
                            parent.location.reload();
                        },1000);

                    } else {
                        layer.msg('操作失败'+resData.status,{icon: 2});
                    }
                },
                error:function () {


                }
            });
        });




    });


</script>



</body>
</html>
